package com.tm.fiverole.controller;

import com.tm.fiverole.entity.RoleEntity;
import com.tm.fiverole.result.Result;
import com.tm.fiverole.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wangSang
 * @create 2022-08-18 18:59
 */
@RestController
@RequestMapping("role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    /***
     * 查询角色
     * @param id
     * @return
     */
    @GetMapping("queryRoleId/{id}")
    public Result  queryRoleId (@PathVariable(value = "id") Integer id){


        return roleService.queryRoleId(id);
    }
    @PostMapping("addRole")
    public Result  addRole (@RequestBody RoleEntity roleEntity){


        return roleService.addRole(roleEntity);
    }

    @PutMapping("updateRole")
    public Result  updateRole (@RequestBody RoleEntity roleEntity){


        return roleService.updateRole(roleEntity);
    }

    @DeleteMapping("deleteRole/{id}")
    public Result  deleteRole (@PathVariable(value = "id") Integer id){


        return roleService.deleteRole(id);
    }

}
